home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwspx.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  9KB  |  316 lines

  1. {$B-,V-,X+}
  2.  
  3. UNIT nwSPX;
  4.  
  5. { nwSPX unit as of 950301 / NwTP 0.6 API. (c) 1993,1995, R. Spronk }
  6. { NOTE: These SPX calls are not documented in this version }
  7.  
  8. INTERFACE
  9.  
  10. Uses Dos,nwMisc,nwIPX;
  11.  
  12. { Primary SPX calls:           Subf:  Comments:
  13.  
  14.   SPXabortConnection            14
  15.   SPXGetConnectionStatus        15
  16.   SPXestablishConnection        11
  17. * SPXinitialize                 10
  18.   SPXlistenForConnection        12
  19.   SPXlistenForSequencedPacket   17
  20.   SPXsendSequencedPacket        16
  21.   SPXTerminateConnection        13
  22.  
  23.   Secondary calls:
  24.  
  25. * SPXpresent
  26.  
  27.   Notes: (1) These functions use INT 21 and are not to be called from
  28.              within an ESR.
  29. }
  30.  
  31. Var Result:word; { unit errorcode variable }
  32.  
  33. Type TspxHeader=Record
  34.                IPXhdr        :TipxHeader;  { SPX will set packetType to 5 }
  35.                connControl   :byte; { rarely used, set to $00 }
  36.                                     { ignored by SPX, but passed on to receiver:
  37.                                       $10 End of message; $20 Attention packet }
  38.                dataStreamType:Byte; { to be used by higher level protocols.
  39.                                       nust be < $FE, passed on to receiver }
  40.                sourceConnId,
  41.                destConnId    :Word;
  42.                sequenceNbr,
  43.                acknowledgeNbr,
  44.                allocationNbr :Word;
  45.                end;
  46.     { Fields within IPX and SPX are high-low. Byte swapping will be done
  47.       by the IPX functions, except network and node addresses. }
  48.  
  49. Type TSPXconnectionInformation
  50.         =record
  51.          ConnectionState        :Byte; { all fields are returned hi-lo }
  52.          WatchDogState          :Byte;
  53.          LocalSPXConnectionId   :Word;
  54.          RemoteSPXConnectionId  :Word;
  55.          SequenceNumber         :Word;
  56.          LocalAcknowledgeNumber :Word;
  57.          LocalAllocationNumber  :Word;
  58.          RemoteAcknowledgeNumber:Word;
  59.          RemoteAllocationNumber :Word;
  60.          LocalSocket            :Word;
  61.          ImmediateAddress       :TnodeAddress;
  62.          RemoteAddress          :TinterNetworkAddress;
  63.          RetransmissionCount    :Word;
  64.          EstimatedRoundTripDelay:Word;
  65.          RetransmittedPackets   :Word;
  66.          SuppressedPackets      :Word;
  67.       end;
  68.  
  69. Function SPXpresent:boolean;
  70. { Determines if SPX is installed. Calls SPXInitialize. }
  71.  
  72. {IPX/SPX: 10h}
  73. Function SpxInitialize(Var SPXhiVer,SPXloVer:Byte;
  74.                        Var MaxConn,AvailConn:word):boolean;
  75. { Determines if SPX is loaded. (this function also tests the presence of IPX, }
  76. { as IPX is required for running SPX. Remember: Netware 2.2 allows IPX and SPX    }
  77. { to be loaded seperately, so only IPX may be present. }
  78.  
  79. {IPX/SPX: 11h}
  80. Function SPXestablishConnection(retryCount:byte; WatchdogFlag:Byte;
  81.                          {i/o}  Var ECB:Tecb;
  82.                          {out}  Var SPXconnectionID:Word):boolean;
  83.  
  84. {IPX/SPX: 12h}
  85. Function SPXlistenForConnection(retryCount:Byte; WatchdogFlag: Byte;
  86.                                 Var ECB:Tecb            ):boolean;
  87.  
  88. {IPX/SPX: 15h}
  89. Function SPXGetConnectionStatus(SPXconnectionID:word;
  90.                             Var connInfo:TSPXconnectionInformation):boolean;
  91.  
  92. {IPX/SPX: 13h}
  93. Function SPXTerminateConnection(SPXconnectionID:Word; ECB:Tecb):boolean;
  94.  
  95. {IPX/SPX: 14h}
  96. Function SPXabortConnection(SPXconnectionID:Word):boolean;
  97.  
  98. {IPX/SPX: 16h}
  99. Function SPXsendSequencedPacket(SPXconnectionID:Word; Var ECB:Tecb):boolean;
  100.  
  101. {IPX/SPX: 17h}
  102. Function SPXlistenForSequencedPacket(Var ECB:Tecb):boolean;
  103.  
  104. {************** Secondary Procedures ***************************************}
  105.  
  106. IMPLEMENTATION {==============================================================}
  107.  
  108. CONST
  109.     SPX_WATCHDOG_ENABLED     =1;
  110.     SPX_WATCHDOG_DISABLED    =0;
  111.     SPX_DEFAULT_RETRY_COUNT  =0;
  112.  
  113.     SPX_POOL_SIZE         =10;
  114.  
  115.     SPX_MAX_DATA_LENGTH  =534;
  116.  
  117. {IPX/SPX: 10 }
  118. Function SpxInitialize(Var SPXhiVer,SPXloVer:Byte;
  119.                        Var MaxConn,AvailConn:word):boolean;
  120. Var Regs:registers;
  121. begin
  122. With regs
  123.  do begin
  124.     al:=$00;
  125.     bx:=$0010;
  126.     IpxSpxSystemCall(Regs);
  127.     result:=regs.al;
  128.  
  129.     if AL<>$FF
  130.      then begin
  131.           result:=$FF;
  132.           SpxInitialize:=false
  133.           end
  134.      else begin
  135.           SPXhiVer:=BH;
  136.           SPXloVer:=BL;
  137.           MaxConn:=CX;
  138.           AvailConn:=DX;
  139.           result:=$00;
  140.           SpxInitialize:=true;
  141.           end;
  142.     end; {with}
  143. { resultcodes: $00 successfull (SPX installed); $FF SPX not installed }
  144. end;
  145.  
  146. Function SpxPresent:boolean;
  147. Var SpxHi,SpxLo:Byte;
  148.     MaxConn,AvConn:word;
  149. begin
  150. SpxPresent:=( IpxPresent and SpxInitialize(SpxHi,SpxLo,MaxConn,AvConn) );
  151. end;
  152.  
  153. {IPX/SPX: 11h}
  154. Function SPXestablishConnection(retryCount:byte; WatchdogFlag:Byte;
  155.                          {i/o}  Var ECB:Tecb;
  156.                          {out}  Var SPXconnectionID:Word):boolean;
  157. Var regs:registers;
  158. begin
  159. With regs
  160.  do begin
  161.     BX:=$0011;
  162.     AL:=retryCount;
  163.     AH:=WatchDogFlag;
  164.     ES:=Seg(ECB);
  165.     SI:=ofs(ECB);
  166.     end;
  167. IpxSpxSystemCall(Regs);
  168. result:=regs.AL;
  169. SPXconnectionID:=regs.DX;
  170. SPXestablishConnection:=(result=$00);
  171. { resultcodes: $00 SPX Attempting to contact destination socket;
  172.                $EF Local connection table full;
  173.                $FD Fragment count not 1 AND/OR Buffer size not 42;
  174.                $FF Send Socket not open OR IPX/SPX not initialized. }
  175. end;
  176.  
  177.  
  178. {IPX/SPX: 12h}
  179. Function SPXlistenForConnection(retryCount:Byte; WatchdogFlag: Byte;
  180.                                 Var ECB:Tecb            ):boolean;
  181. Var regs:Registers;
  182. begin
  183. With regs
  184.  do begin
  185.     BX:=$0012;
  186.     AL:=retryCount;
  187.     AH:=WatchdogFlag;
  188.     ES:=Seg(ECB);
  189.     SI:=Ofs(ECB);
  190.     IpxSpxSystemCall(Regs);
  191.     result:=AL;
  192.     if result<>$FF
  193.      then result:=$00;
  194.     end;
  195. SPXlistenForConnection:=(result=$00);
  196. end;
  197.  
  198. {IPX/SPX: 15h}
  199. Function SPXGetConnectionStatus(SPXconnectionID:word;
  200.                             Var connInfo:TSPXconnectionInformation):boolean;
  201. Var regs:Registers;
  202. begin
  203. With regs
  204.  do begin
  205.     BX:=$0015;
  206.     DX:=SPXconnectionID;
  207.     ES:=Seg(connInfo);
  208.     SI:=Ofs(connInfo);
  209.     IpxSpxSystemCall(Regs);
  210.     Result:=AL;
  211.     end;
  212. if result=0
  213.  then begin
  214.       With ConnInfo
  215.        do begin { force all returned words lo-hi }
  216.           LocalSPXConnectionId   :=Swap(LocalSPXconnectionID);
  217.           RemoteSPXConnectionId  :=Swap(RemoteSPXconnectionID);
  218.           SequenceNumber         :=swap(SequenceNumber);
  219.           LocalAcknowledgeNumber :=swap(LocalAcknowledgeNumber);
  220.           LocalAllocationNumber  :=swap(LocalAllocationNumber);
  221.           RemoteAcknowledgeNumber:=swap(RemoteAcknowledgeNumber);
  222.           RemoteAllocationNumber :=swap(RemoteAllocationNumber);
  223.           LocalSocket            :=swap(LocalSocket);
  224.           RemoteAddress.socket   :=swap(remoteAddress.socket);
  225.           RetransmissionCount    :=swap(RetransmissionCount);
  226.           EstimatedRoundTripDelay:=swap(EstimatedRoundTripDelay);
  227.           RetransmittedPackets   :=swap(RetransmittedPackets);
  228.           SuppressedPackets      :=swap(SuppressedPackets);
  229.           end;
  230.       end;
  231. SPXGetConnectionStatus:=(result=0);
  232. { Resulcodes: $00 Connection is active; $EE No such connection }
  233. end;
  234.  
  235.  
  236. {IPX/SPX: 13h}
  237. Function SPXTerminateConnection(SPXconnectionID:Word; ECB:Tecb):boolean;
  238. Var regs:Registers;
  239. begin
  240. with regs
  241.  do begin
  242.     BX:=$0013;
  243.     DX:=SPXconnectionID;
  244.     ES:=seg(ECB);
  245.     SI:=Ofs(ECB);
  246.     end;
  247. IpxSpxSystemCall(Regs);
  248. result:=regs.al;
  249. if result<>$FF
  250.  then result:=$00;
  251. SPXterminateConnection:=(result=0);
  252. {resultcodes: $00 SPX attempting to break connection;
  253.               $FF IPX/SPX not loaded.  }
  254. end;
  255.  
  256. {IPX/SPX: 14h}
  257. Function SPXabortConnection(SPXconnectionID:Word):boolean;
  258. Var regs:Registers;
  259. begin
  260. with regs
  261.  do begin
  262.     BX:=$0014;
  263.     DX:=SPXconnectionID;
  264.     end;
  265. IpxSpxSystemCall(Regs);
  266. result:=regs.al;
  267. if result<>$FF
  268.  then result:=$00;
  269. SPXabortConnection:=(result=0);
  270. {resultcodes: $00 SPX trying to unilateral break the connection;
  271.               $FF IPX/SPX not loaded. }
  272. end;
  273.  
  274. {IPX/SPX: 16h}
  275. Function SPXsendSequencedPacket(SPXconnectionID:Word; Var ECB:Tecb):boolean;
  276. Var regs:Registers;
  277. begin
  278. with regs
  279.  do begin
  280.     BX:=$0016;
  281.     DX:=SPXconnectionID;
  282.     ES:=Seg(ECB);
  283.     SI:=Ofs(ECB);
  284.     end;
  285. IpxSpxSystemCall(Regs);
  286. result:=regs.al;
  287. if result<>$FF
  288.  then result:=$00;
  289. SPXsendSequencedPacket:=(result=0);
  290. {resultcodes: $00 SPX will attempt to send packet;
  291.               $FF IPX/SPX not loaded. }
  292. end;
  293.  
  294. {IPX/SPX: 17h}
  295. Function SPXlistenForSequencedPacket(Var ECB:Tecb):boolean;
  296. Var regs:Registers;
  297. begin
  298. with regs
  299.  do begin
  300.     BX:=$0017;
  301.     ES:=Seg(ECB);
  302.     SI:=Ofs(ECB);
  303.     end;
  304. IpxSpxSystemCall(Regs);
  305. result:=regs.al;
  306. if result<>$FF
  307.  then result:=$00;
  308. SPXlistenForSequencedPacket:=(result=0);
  309. {resultcodes: $00 SPX waits for incoming packets;
  310.               $FF IPX/SPX not loaded. }
  311. end;
  312.  
  313. {************** Secondary Procedures ***************************************}
  314.  
  315. end.
  316.